﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;

namespace CTEA_INDIA
{
    public partial class View_Hire_Equipment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["CTEA"].ConnectionString;
            populateHireEqupm();

        }
        public void populateHireEqupm()
        {

            DataSet ds = BAL.Customers.ViewllEquipments();
            gdHireEquipment .DataSource = ds;
            gdHireEquipment.DataBind();
        
        }

        protected void gdHireEquipment_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gdHireEquipment.PageIndex = e.NewPageIndex;
            populateHireEqupm();
        }

        protected void gdHireEquipment_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton lEdit = (LinkButton)e.Row.FindControl("lnkEdit");
                Button update = (Button)e.Row.FindControl("btnUpdate");
                LinkButton lDelete = (LinkButton)e.Row.FindControl("lnkDelete");
                lDelete.CommandArgument = e.Row.RowIndex.ToString();
            }

        }

        protected void lnkView_Click(object sender, EventArgs e)
        {
            LinkButton lnkVw = sender as LinkButton;
            GridViewRow row = (GridViewRow)lnkVw.Parent.Parent;
           // int locationID = Convert.ToInt32(ddlLocation.SelectedValue);


            int Cid = Convert.ToInt32(gdHireEquipment.DataKeys[row.RowIndex]["HireId"]);


            string[] Details = BAL.Customers.GetHireEquipmentById(Cid);

            lblCompanyName.Text = Details[1];
            lblAuthorityName.Text = Details[2];
            lblAddress.Text = Details[3];
            lblTitleOfProduction.Text = Details[4];
            lblLanguageOfProduction.Text = Details[5];
            lblmot.Text = Details[6];
            lblLocation.Text = Details[7];
            lblPop.Text = Details[8];
            lblStrDate.Text = DateTime.Parse(Details[9].ToString()).ToShortDateString().ToString();
            lblEndDate.Text = DateTime.Parse(Details[10].ToString()).ToShortDateString().ToString();
            lblTotalDays.Text = Details[11];
            lblDelTime.Text = Details[12] + ":" + Details[13] + ":" + Details[14];
            lblRecTime.Text = Details[15] + ":" + Details[16] + ":" + Details[17];
            lblHoe.Text = Details[18];
            lblPayMode.Text = Details[19];
            lblBalance.Text = Details[23]; 



            lnkView_ModalPopupExtender.Show();

            //document.getElementById("totalDaystd").innerHTML = "<asp:TextBox ID=\"txtDaysText\" runat=\"server\" ReadOnly=\"True\" Text=\""+ days +"\"></asp:TextBox>";

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }

        
    }
}